<template>
	<view class="mh100 pb115">
		<view style="padding: 20rpx 15rpx;">
			<view class="bs15 bf f-x-bt p34">
				<view class="f32">提现方式</view>
				<view class="f-c">
					<view class="mr10" style="width: 20rpx;height: 20rpx;">
						<mg-img src="/static/img/2.png" />
					</view>
					<view class="mr10">{{cashOutType}}</view>
					<view class="mr10 f20 b-d" style="padding: 1rpx 2rpx;">默认</view>
					<!-- <view><text style="vertical-align: baseline;" class="iconfont iconright f20" /></view> -->
				</view>
			</view>

			<view class="bs15 bf mt20 p34">
				<view class="f-x-bt">
					<view class="f32">提现金额（元）</view>
				</view>
				<view><input class="cash-input" v-model="cashOutMoney" placeholder-style="color:#DDD" type="number"
						value="" placeholder="请输入提现金额" /></view>
				<view class="mt10 f-row">
					<view class="mr20 c9">可提现余额{{txxx.money || 0.00}}元</view>
					<view style="color: #FE9367;" @click="allCashOut">全部提现</view>
				</view>
				<view class="c9">
				              最低提现金额：<span class="cf5">{{ txxx.downMoney || 0 }}元</span> ；
				              提现服务费收费标准：<span class="cf5">{{ txxx.rate || 0 }}%每笔</span>(最低收取：<span class="cf5">{{ txxx.rateDownMoney || 0 }}元</span>)
				</view>
			</view>
			<block v-if="!disabled">
				<button type="default" class="mt50 wei f28 bs20" style="background: #FE9367;padding: 15rpx 20rpx;"
					@click="save">立即提现</button>
			</block>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex';
	import utils from '@/common/utils.js'
	import uniNavBar from '@/components/third/uni-nav-bar.vue';
	export default {
		name: 'my-index',
		components: {
			uniNavBar
		},
		data() {
			return {
				disabled:false,
				opcity: 0,
				cashOutMoney: '',
				navigateArr: [{
						name: '提现',
						icon: '/static/img/2.png',
						url: '/yb_shd/my/wallet/cash-out'
					},
					{
						name: '银行卡',
						icon: '/static/img/2.png',
						url: ''
					},
					{
						name: '转账',
						icon: '/static/img/2.png',
						url: ''
					}
				],
				txxx: {},
				cashOutType: ''
			};
		},
		computed: {
			...mapState(['sjxx', 'version'])
		},
		onLoad(options) {
			this.util.setNT('提现申请');
			this.getData()
		},
		onShow() {

		},
		methods: {
			...mapMutations(['delAccount', 'removeAccount']),
			getData() {
				this.util
					.request({
						url: this.api.sjtxxx,
						method: 'GET'
					})
					.then(res => {
						if (res.code == 1) {
							this.txxx = res.data;
							switch (parseInt(this.txxx.type)) {
								case 0:
									this.util.message('未在平台设置提现方式', 3,3000);
									this.disabled = true
									break;
								case 1:
									this.cashOutType = '微信'
									break;
								case 2:
									this.cashOutType = '支付宝'
									break;
								case 3:
									this.cashOutType = '银行卡'
									break;
								default:
									break;
							}
							this.showloading = false;
						} else {
							this.util.message(res.msg, 3);
							this.showloading = false;
						}
					});
			},
			goDl(v) {
				uni.setStorageSync('fwb', v.body);
				this.go({
					t: 1,
					url: `/yb_shd/my/other/gywm?t=${v.title}&p=4`
				});
			},
			allCashOut() {
				this.cashOutMoney = this.txxx.money
			},
			save() {
				if(this.txxx.type !== 0){
				this.util
					.request({
						url: this.api.sjtx,
						method: 'GET',
						data: {
							money: this.cashOutMoney
						}
					})
					.then(res => {
						if (res.code == 1) {
							this.util.message('提现成功', 1, 1000);
							utils.swnb(1000)
						} else if(res.code == 2) {
							this.util.message(res.msg, 3);
						}
					}).catch(e=>{
						if(e.code === 2){
							this.util.message(e.msg,3, 1000);
						}
					});
				} else{
					this.util.message('未在平台设置提现方式', 3);
				}
			}
		}
	};
</script>
<style scoped lang="scss">
	.cash-input {
		height: 160rpx;
		font-size: 50rpx;
		padding: 30rpx 0;
		border-bottom: 1px solid #ddd;
	}
</style>
